Skip to content

feat(core): project identity (data foundation for session library)#121

Closed
graydawnc wants to merge 12 commits intomainfrom
feat/project-identity
Closed

feat(core): project identity (data foundation for session library)#121
graydawnc wants to merge 12 commits intomainfrom
feat/project-identity

Conversation

@graydawnc
Copy link
Copy Markdown
Collaborator

Summary

PR 1 of 7 in the Session Library redesign. Pure data-layer change with no UI changes.

  • Adds cross-source project identity computation: git_remote → git_common_dir → manifest_path → loose → path (short-circuit priority)
  • Migrates DB to user_version 6: identity_kind / identity_key columns on projects + index, plus project_groups_v view that aggregates same-identity rows across sources
  • Backfills existing rows on migration (idempotent, transactional)
  • New listProjectGroups() query for upcoming UI consumption
  • Identity-derived display name falls back to existing resolveProject name for new sessions

Spec & plan

  • Spec: ~/Documents/dev-docs/spool/session-library.md §4
  • Plan: ~/Documents/dev-docs/spool/plans/session-library-pr1.md
  • Master PR sequence: ~/Documents/dev-docs/spool/plans/session-library.md

Files changed

packages/core/src/projects/
  identity.ts          158  (5-step priority, IdentityFs DI)
  identity.test.ts     114  (10 cases incl. worktree + null-cwd loose)
  display-name.ts        6
  display-name.test.ts  18
  groups.ts             29  (listProjectGroups)
  groups.test.ts        54
  fs.ts                 14  (realFs adapter, 5s spawn timeout)
  e2e.test.ts           45  (cross-source unification)
packages/core/src/db/
  db.ts                +55  (v6 migration + backfillProjectIdentities)
  migration-v6.test.ts  79  (5 cases incl. backfill)
  migration-v5.test.ts  ±6  (assertion adapt)
  queries.ts            ±7  (signature + identity persistence)
  queries.test.ts       34  (identity persistence)
  stars.test.ts         +1  (caller adaptation)
packages/core/src/sync/
  syncer.ts             ±9  (computeIdentity wired in)
packages/core/src/types.ts +22  (ProjectIdentity, ProjectGroup types)

11 commits, ~640 LOC net. Logical units: types → identity computation → display name util → migration v6 → query persistence → syncer wiring → backfill → groups query → e2e test → strict-tsc fix → final fixes (spawn timeout + portable test).

Test plan

  • pnpm --filter @spool-lab/core test — 73 passed (15 test files)
  • pnpm --filter @spool-lab/core build — clean
  • Full workspace pnpm build (Turbo, 3 packages) — clean
  • Existing v5 migration test still passes
  • Existing stars test still passes
  • Existing syncer test passes un-touched (cwd /tmp/... short-circuits to loose, no real git spawn)

Noteworthy / deferred

  • getOrCreateProject does not refresh display_name on existing rows. Pre-existing pattern; identity columns are correctly set on insert. If a project's package.json name field changes after first index, the display name stays stale. Future PR can add ON CONFLICT DO UPDATE.
  • listProjectGroups not yet exported from index.ts. Intentional — UI consumes it in PR 3 (Library Shell + Sidebar). Public surface stays unchanged.
  • spawnSync has a 5s timeout. Mirrors the fix already applied in Spool Daemon to prevent hung git config calls (slow ssh-agent, network mounts) from blocking indexing.
  • Spec deviation (cosmetic): view uses MIN(p.display_name) not COALESCE(MIN(display_name), MIN(slug)). Equivalent in practice — display_name is NOT NULL.

What this PR does NOT do

Per the master PR sequence:

  • No sidebar / project list UI (PR 3)
  • No Star UI hide (PR 2)
  • No Pin (PR 5)
  • No search migration (PR 6)
  • No session detail integration (PR 7)
  • No DESIGN.md changes (PR 3)

The new project_groups_v view is built but unused by the UI — by design.

@graydawnc graydawnc marked this pull request as draft April 28, 2026 16:09
@graydawnc graydawnc closed this Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant